package com.songjia.springcloud.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.songjia.common.model.base.ResponseInfo;

/**
 * 
 * 
 * @Description: Feign继承特性
 *
 * @author: songjia
 * @date: 2018年8月30日 下午8:00:46
 */
@RestController
public class DeptController {

	/**
	 * 获取部门详情
	 * 
	 * @param id
	 * @return
	 */
	@GetMapping("/dept/{id}")
	@HystrixCommand(fallbackMethod = "getDeptDetailFallback")
	public ResponseInfo getDeptDetail(@PathVariable("id") Long id) {
		// 抛出异常
		System.err.println(1 / 0);
		return ResponseInfo.success(null);
	}

	public ResponseInfo getDeptDetailFallback(@PathVariable("id") Long id) {
		return ResponseInfo.fail("获取部门详情出现异常, id=" + id);
	}
}
